﻿using System;
using System.Collections.Generic;
using System.Text;

namespace MaximServices.Model
{
    public class ResultModel<T>
    {
        public int code { get; set; }

        public string msg { get; set; }

        public T data { get; set; }
    }

    public class BuildResult
    {
        public static ResultModel<T> Success<T>(T data)
        {
            return new ResultModel<T>
            {
                code = (int)ErrorCode.Normal,
                msg = "success",
                data = data
            };
        }

        public static ResultModel<T> Error<T>(string msg, T data = default(T))
        {
            return new ResultModel<T>
            {
                code = (int)ErrorCode.Error,
                msg = msg,
                data = data
            };
        }
    }

    public enum ErrorCode
    {
        Error = -1,
        Normal = 1
    }
}
